<template>
  <div class="goods-hot">
    <h3>{{title}}</h3>
    <div>
      <GoodsItem v-for="i in goodList" :good="i" :key="i.id"/>
    </div>
  </div>
</template>

<script setup >
import GoodsItem from '@/views/category/components/good-item.vue'
import { getGoodsHot } from '@/api/product'
import { useRoute } from 'vue-router'
const route = useRoute()
const props = defineProps({
  type: {
    // 热榜类型
    type: Number,
    default: 1
  }
})
const types = {
  1: '24小时热销榜',
  2: '周榜',
  3: '总热销榜'
}
const title = computed(() => {
  return types[props.type]
})
// 获取数据
const goodList = ref([])
getGoodsHot({ id: route.params.id, type: props.type }).then(({ result }) => {
  goodList.value = result
  console.log(result)
})
</script>

<style scoped lang='less'>
.goods-hot {
  h3 {
    height: 70px;
    background: @helpColor;
    color: #fff;
    font-size: 18px;
    line-height: 70px;
    padding-left: 25px;
    margin-bottom: 10px;
    font-weight: normal;
  }

  ::v-deep .goods-item {
    background: #fff;
    width: 100%;
    margin-bottom: 10px;

    img {
      width: 200px;
      height: 200px;
    }

    p {
      margin: 0 10px;
    }

    &:hover {
      transform: none;
      box-shadow: none;
    }
  }
}
</style>
